package com.example.armmvvm.ui.constraint.normalfallview

import android.view.View
import android.view.ViewGroup
import androidx.core.view.updateLayoutParams
import androidx.lifecycle.LifecycleOwner
import com.example.arm.ext.dpInt
import com.example.armmvvm.R
import com.example.armmvvm.databinding.LayoutBottomBehaviorTestBinding
import com.example.armmvvm.ui.fallview.AnchorFallView
import com.example.armmvvm.ui.fallview.AnchorFallViewSetting
import com.example.armmvvm.ui.fallview.FallViewMode

/**
 *  author : yanghaozhang
 *  date : 2022/10/18 17:48
 *  description :
 */
class NormalThreeStateFallView(lifecycleOwner: LifecycleOwner, viewContainer: ViewGroup) :
    AnchorFallView(lifecycleOwner, viewContainer, R.layout.layout_bottom_behavior_test) {

    lateinit var binding: LayoutBottomBehaviorTestBinding

    override fun updateView(view: View) {
        binding = LayoutBottomBehaviorTestBinding.bind(view).apply {
            scrollView.updateLayoutParams {
                height = ViewGroup.LayoutParams.WRAP_CONTENT
            }
            blankView.updateLayoutParams {
                height = 950.dpInt
            }
            tvContent.text = "NormalThreeStateFallView"
            tvContent.setOnClickListener {
                NormalThreeNoTopStateFallView(lifecycleOwner, viewContainer).show()
            }
        }
    }

    override fun bottomFallViewSetting(view: View): AnchorFallViewSetting? {
        return AnchorFallViewSetting(view).apply {
            mode = FallViewMode.THREE_STATE
            calcHeight = {
                peekHeight = binding.tvContent.height
                anchorHeight = binding.tvContent.height + 50.dpInt
            }
        }
    }
}